﻿$(function () {
    // 自定义验证
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                inputNumebr:null
            }
        },
        watch: {
            inputNumebr: function (value) {
                const vm = this;
                if (value) {
                    vm.navigateToCheckIn();
                }
            }
        },
        methods: {
            // 跳转到"签到"
            navigateToCheckIn() {
                const vm = this;
                window.location.href = `/Appointments/SelfServiceTerminal/CheckIn?number=${vm.inputNumebr}`
            },
            // 跳转到 "取消"
            navigateToCancel() {
                const vm = this;
                window.location.href = `/Appointments/SelfServiceTerminal/Cancel`
            },
            // 凭证打印
            navigateToPrint() {
                const vm = this;
                window.location.href = `/Appointments/SelfServiceTerminal/Print`
            },
            getDepCodesFromQuery() {
                const vm = this;
                var depCodes = window.utils.getQuery('depCodes');
                if (depCodes) {
                    localStorage.removeItem('depCodes');
                    localStorage.setItem('depCodes', depCodes);
                }
            },
            initInput() {
                const vm = this;
                vm.$refs.input.focus();
                // 始终保持聚焦
                vm.$refs.input.addEventListener('blur', () => {
                    setTimeout(() => {
                        vm.$refs.input.focus();
                    }, 0);
                })
            },
        },
        created() {
            const vm = this;
          
        },
        mounted() {
            const vm = this;
            vm.initInput();
            vm.getDepCodesFromQuery();
        }
    });
});